export const state = () => ({
    demoData: {},
    isLoading: false,
  })
  
  export const mutations = {
    GET_SERVER_DATA(state, data){
      state.demoData = data
    },
    START_LOADING(state) {
        state.isLoading = true;
    },
    END_LOADING(state) {
        state.isLoading = false;
    },
  }

  export const actions = {
    getServerData({ commit, state }, { $api, params={} }) {
        commit('START_LOADING');
        return $api.get('/app/data.json', params).then(response => {
            const { data: { data } } = response
            commit('GET_SERVER_DATA', data);
            commit('END_LOADING');
            return response;
        });
    },
  }